<?php
namespace Macaca\Model\Admin;

use Macaca\Model\Base;
use Monkey;

class Article extends Base {

    public $table = 'article'; //'a_id','ac_id','a_name','title','content','keywords','description','add_time','top_sort','click'
    public $priKey = 'a_id';

    public function findList($page = 0, $pageLength = 10) {
        //      'a_id','title',ac_caption,'a_name','top_sort','add_time','click'
        //      'ac_id','content','keywords','description',  article_category.caption(ac_caption)
       return $this->conn->select($this->table, 'a')
            ->join('article_category', 'ac', 'a.ac_id = ac.ac_id')
            ->fields('a_id', 'title', 'a_name', 'top_sort', 'add_time', 'click')
            ->addFields('ac', array('caption' => 'ac_caption'))
            ->orderBy('a.a_id', 'DESC')
            ->range($pageLength, $page*$pageLength)
            ->execute()->fetchAll();
    }

}